<template>
<div :id="$attrs.id" style="width: 100%; height:360px"></div>
</template>
<script>
import * as echarts from 'echarts';
export default {
  name: "lineEchart",
  data(){
    return{
    }
  },
  mounted() {
    this.$nextTick(()=>{
      this.getLine();
    })
  },
  methods:{
    getLine(){
      var chartDom = document.getElementById(this.$attrs.id);
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          top:'10%',
          left: '10%',
          right: '4%',
          bottom: '12%',
          show:false,
        },
        xAxis: [
          {
            type: 'category',
            data: this.$attrs.barXDataList,
            axisTick: {
              alignWithLabel: true
            }
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            type: 'bar',
            barWidth: '20px', // 设置柱状图的宽度为容器宽度的50%
            itemStyle: {
              color: '#00c270' // 设置柱状图的颜色为红色
            },
            data: this.$attrs.barYDataList,
          }
        ]
      };

      option && myChart.setOption(option);
    },
  },
}
</script>

<style scoped lang="scss">

</style>
